function r = trunc_rnd (f, n, a, b)

   ## usage:  r = trunc_rnd (f, n, a, b)
   ##
   ## generate n f random numbers between a and b

   u = rand(n,1) ;
   FA = feval([f, "cdf"], a) ;
   FB = feval([f, "cdf"], b) ;
   FI = [f, "inv"] ;
   r = feval(FI, FA + u * (FB - FA)) ;

endfunction
